home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 301-325 / disk_319 / cnewssrc / cnews.orig.lzh / libc / efopen.c < prev    next >
C/C++ Source or Header  |  1989-06-27  |  572b  |  32 lines

  1. /*
  2.  * efopen - fopen file, exit with message if impossible
  3.  */
  4.  
  5. #include <stdio.h>
  6.  
  7. /* imports from libc */
  8. extern char *strcpy(), *strncat();
  9. extern void error();
  10.  
  11. static char message[] = "can't open file \"%s\" mode ";
  12.  
  13. FILE *
  14. efopen(file, mode)
  15. char *file;
  16. char *mode;
  17. {
  18.     FILE *fp;
  19.     char fullmsg[sizeof(message)+10];
  20.     extern int errno;
  21.  
  22.     errno = 0;        /* Wipe out residue of earlier errors. */
  23.     fp = fopen(file, mode);
  24.     if (fp == NULL) {
  25.         (void) strcpy(fullmsg, message);
  26.         (void) strncat(fullmsg, mode, 10);
  27.         error(fullmsg, file);
  28.         /* NOTREACHED */
  29.     }
  30.     return(fp);
  31. }
  32.